Skip to content

fix(rest): /meta negotiates the request locale against the held locales before it picks a pack - #36561

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-36466-meta-locale-negotiate
Nov 23, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-36466-meta-locale-negotiate

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #36466
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:应用以英文编写、默认面向中文用户、并持有英文语言包时,浏览器语言为美式英语等地区写法的用户,在对象元数据接口里看到的对象名称由中文变为英文原文,和同一请求下保存报错里的名称一致;没有对应语言包的语言仍按默认语言显示。
  • 为什么做:多语言标签统一的后续:让元数据接口和服务端各处读者用同一种方式把地区语言写法对到已有语言包。
  • 出错会怎样:最坏情况是某个地区语言写法的用户看到的对象名称语言不对,不影响数据和权限,合并后可直接回退。
  • 要你做什么:无

What changes

The card's ruling, quoted: "Make the /meta read (packages/rest/src/meta-item-read-gate.ts) negotiate the request tag the way the other readers do before it picks a pack. No spec change."

  • metaTranslateOptions (the ResolveOptions every metadata-document translation builds) now carries locale as the request tag negotiated against the locales the i18n service reports: resolveBundleLocale (@objectstack/spec/system, the platform's one locale ladder) over getLocales(). That is the question objectql's negotiatedMessageLocale and plugin-approvals' negotiatedReaderLocale already ask, over the same set. Neither of those is importable from @objectstack/rest without a new export (objectql does not export it; plugin-approvals is downstream), so a private helper beside it (negotiatedTranslationLocale) repeats only the offered-set plumbing and calls the shared rule. It adds no second rule and no new export.
  • The tag passes through untouched when there is nothing to negotiate against: no service, no getLocales, a throwing, empty or non-array answer, or no match. So a locale the deployment holds no pack for still walks the declared chain to the default locale.
  • Reach: metaTranslateOptions is the one builder, so the item read and the list read on both transports (RestServer and the runtime dispatcher, which share translateMetaDocument / translateMetaList), the view container, the stale-plural rule, the GET /meta types listing and the public form's object labels (translateOptionsFor delegates here) all read the negotiated tag. The doc locale collapse (resolveDocLocale) and extractLocale's other callers (export, import template) are untouched.
  • No packages/spec change.

Tests

New top-level describe #36466 §7 in packages/rest/src/meta-i18n-declared-fallback-chain.test.ts, the shared harness of the /meta i18n pins (§6 is this deployment's sourceLocale case). The fixture is sourceLocale: 'en', defaultLocale: 'zh-CN', the chain collapsed to zh-CN, a zh-CN pack, and an en pack that holds no account rows.

  • Card pin 1: an en-US request with only an en pack reads Account from /meta (item read, list read, and bare en agree).
  • Card pin 2: a request for a locale with no pack at all (fr-FR), and a header-less request, still read the default locale (客户).
  • Control: with no en locale held, en-US has nothing to negotiate to and walks to 客户; zh still reads the zh-CN pack.
  • Acceptance parity: for en-US and fr-FR, /meta's label and the label objectql's DELETE_RESTRICTED (code and status asserted) names on the same i18n service are the same (Account and 客户), and the other one is absent.
  • Cached arm (getMetaItemCached, the default door): en-US is served Account and en the same body; the en-US validator revalidates its own request (304); sent with zh-CN or fr-FR it answers 200 with 客户, never a 304 for the English body.

Acceptance notes

  • Cache key (measured, unchanged here). The cached arm's validator is the protocol's hash of the untranslated document folded with the tag the request SENT (extractLocale, meta-item-read-routes.ts, [P2] i18n: zh-CN ↔ English switch occasionally garbled — requires page refresh #1319). Translation runs after it with the negotiated tag. So within a running server each sent tag maps to one body: en-US and en get separate validators over identical bodies (fewer shared 304s, never a wrong one), and a validator never crosses languages (pinned above). Keying the validator on the negotiated tag would need meta-item-read-routes.ts, outside this card's file surface, so it is raised as a question in the report. Not pinned, because it is already true of any pack edit: the validator hashes no translation input, so a client that cached an en-US body before this deploy can be answered 304 on the old 客户 body until the document changes.
  • plugin-security does not negotiate (measured; the card's premise holds for objectql and the fix(objectql,approvals,audit): rule messages, approval object labels and activity-summary labels read as /meta serves them in a declared sourceLocale #36464 readers only). Reading taken with a scratch copy of controlled-by-parent-master-edit-user-message.test.ts (deleted, not committed) on an i18n service with sourceLocale: 'en', defaultLocale/fallback zh-CN and an en pack: the master-detail refusal's userMessage names the master Contract for en, 合同 for en-US, and Contract for fr-FR. denialLocaleOf returns the raw request tag and denialLabels hands it to translateObject as written. So after this PR, /meta (Contract) and plugin-security (合同) still disagree for en-US, and for fr-FR (/meta serves 合同, plugin-security falls back to an en sentence naming Contract). This is reported for the seat to file, not fixed here.
  • The public form and the GET /meta types listing negotiate too, because they read the same builder. That is the same defect class on the same function; no pin was added for them.

Verification

Two-minute check: pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/meta-i18n-declared-fallback-chain.test.ts. Expect 30 passed, including #36466 §7 … an en-US request with only an en pack reads Account.

Read first:

  1. packages/rest/src/meta-item-read-gate.ts, the metaTranslateOptions hunk (locale: negotiatedTranslationLocale(service, locale)) and the new helper below it.
  2. packages/rest/src/meta-i18n-declared-fallback-chain.test.ts, the #36466 §7 describe (the parity and cached-arm cases).
Test readings (head 5555e3e)
  • pnpm --filter @objectstack/rest test && pnpm --filter @objectstack/rest typecheck under the verify lock: Test Files 427 passed (427), Tests 8788 passed, 351 skipped (9139); tsc --noEmit and check:test-typecheck OK (0 files in debt). Lock VERDICT command-exit 0.
  • New describe alone: Test Files 1 passed (1), Tests 30 passed (30). Lock VERDICT command-exit 0.
  • Dependency closure built first: pnpm --workspace-concurrency=2 --filter '@objectstack/rest^...' build, lock VERDICT command-exit 0. The parity case reads @objectstack/objectql from that build.
Ablation (fix committed first)

node scripts/ablation-replace.mjs --file packages/rest/src/meta-item-read-gate.ts --anchor 'locale: negotiatedTranslationLocale(service, locale),' --replacement 'locale, /* ABLATION-36466 */' -- …vitest run … meta-i18n-declared-fallback-chain.test.ts: anchor 1 to 0, marker 0 to 1, blob 3b1e09164a86 to e2c5192f903c. The test imports ./rest-server.js from source, so no dist step is involved. Result: 3 failed, 27 passed. Red: an en-US request with only an en pack reads Account, for the same request, /meta and objectql name the object with the same label, and the cached-arm case. The no-pack, no-en and zh controls stayed green. Restore: blob equals HEAD (3b1e09164a86), and git diff HEAD is empty.

Gates

Derived with node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack at 5555e3e: 69 commands (3 changed paths). Each was run with stdin closed and its exit captured before any pipe.

  • 69 of 69 exit 0. Two needed a second pass. check:type-check-debt hit the per-command 420 s cap (exit 124) on the first pass; re-run alone, it reported OK — 0 ledger entr(ies) re-measured … 0 raw tsc error(s), exit 0. check:dual-build-cjs-loads exited 3 (PREREQUISITE NOT MET, no full build); after pnpm turbo run build --concurrency=2 --filter='!@objectstack/docs' (lock VERDICT command-exit 0, 120/120 tasks) it reported 124 published require entry point(s) across 72 package(s) load, exit 0.
  • --ran reconciliation: 69 derived famil(ies) accounted for — 69 run, 0 NOT-MEASURED.
  • node scripts/pm/overlap-check.mjs --branch=HEAD: VERDICT clean exit 0 (merges cleanly with origin/main d463c46; no open PR head shares a file).
  • CI at 5555e3e: all 53 check-runs completed, each success or skipped. Among them: Lint & Repo Gates, TypeScript Type Check, Test Core (10/10), Build Core, Governed Surface Queue Guard, Live E2E UI, Test UI, Dogfood Regression Gate, Check Changeset.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 68 of 251 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 19 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json c5f8588b301d09d6a66c7f2a51d205d090ce7cdc → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 8f420eb98ede70b30e6b9e86a4c6793c96f273be — the merge of head 5555e3ea7758a4d1e8a299de7eb2263f9dbfd448 into base c5f8588b301d09d6a66c7f2a51d205d090ce7cdc, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 8f420eb98ede70b30e6b9e86a4c6793c96f273be && git checkout 8f420eb98ede70b30e6b9e86a4c6793c96f273be
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c5f8588b301d09d6a66c7f2a51d205d090ce7cdc 5555e3ea7758a4d1e8a299de7eb2263f9dbfd448 && git checkout -B drift-repro c5f8588b301d09d6a66c7f2a51d205d090ce7cdc && git merge --no-ff 5555e3ea7758a4d1e8a299de7eb2263f9dbfd448

node scripts/docs-audit/affected-docs.mjs --json c5f8588b301d09d6a66c7f2a51d205d090ce7cdc

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

席位核对

ACCEPT — PR #36561 @ 5555e3e (head of record, full sha on the PR) · card #36466 · L1 first read by area s2-B (area order rule 9) · 2026-11-22T23:58Z

  • Shape: open, draft, base main; first line Fixes #36466, Clause-②: no, Metadata-protocol: none; no closing keyword near another card (l1-face.mjs --pr 36561 CLEAN).
  • Premise: held for /meta, the ruling's scope (claim 7087167586): metaTranslateOptions passed the raw request tag, so en-US with only an en pack walked the declared chain to the default locale. Corrected in one part: the card reads every other reader as already negotiating, but the dev measured that plugin-security's master-detail refusal does not (denialLocaleOf hands the raw tag to translateObject). That reader is outside this card's file surface and is filed as plugin-security: a master-detail write refusal names the master in the default language for a regional request tag (en-US), while /meta and objectql name it in en #36573 (finding, triage knocked on pm:mailbox — triage#1 · hotlong #32588); this PR still closes rest: /meta does not negotiate the request locale, so en-US reads the default locale while other readers read en #36466 as ruled.
  • Scope: 3 files, 249+/2-, on the claim surface: packages/rest/src/meta-item-read-gate.ts (private negotiatedTranslationLocale, calling the shared resolveBundleLocale over getLocales(); no second rule, no new export), a new #36466 §7 describe in the shared /meta i18n harness meta-i18n-declared-fallback-chain.test.ts, one @objectstack/rest patch changeset. No packages/spec change. Not governed, 251 lines.
  • Diff read: the tag passes through untouched when there is nothing to negotiate against (no service, no getLocales, throw, empty or non-array, no match), so a locale with no pack still reaches the default. One builder, so item and list reads on both transports, the types listing and the public form's labels all read the negotiated tag; resolveDocLocale and the export/import callers of extractLocale are untouched.
  • Changeset .changeset/36466-meta-locale-negotiation.md, read against the diff: regional tag to held pack, no-pack locale unchanged, matches.
  • Tests and gates: card pins (en-US reads Account; fr-FR and header-less read 客户), the no-en control, parity with objectql's DELETE_RESTRICTED label on the same service, and the cached arm (own 304, never a 304 across languages). Ablation of the one call: 3 red (en-US, parity, cached arm), controls green, restore blob equal to HEAD. Package suite 8788 passed; 69 of 69 derived gate families run, 0 NOT-MEASURED (ledger /mnt/project-files/objectstack-seat2/36466-gates-ran.txt). Check-runs at this head: 39 success, 18 expected skip, 0 failed, 0 pending.
  • Accepted deviations: none.
  • Out of scope: the cached arm's validator is keyed on the sent tag, not the negotiated one, so en-US and en hold separate validators over identical bodies (fewer shared 304s, never a wrong one; pinned that a validator never crosses languages). Left as is; Acceptance notes, not filed. plugin-security negotiation: filed plugin-security: a master-detail write refusal names the master in the default language for a regional request tag (en-US), while /meta and objectql name it in en #36573.
  • Landing: non-governed, ≤3000 lines, K = 3 ⇒ area lands it in this stroke.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 22, 2026 23:59
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 6bc775f Nov 23, 2026
58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36466-meta-locale-negotiate branch November 23, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rest: /meta does not negotiate the request locale, so en-US reads the default locale while other readers read en

2 participants